/**
 * login
 */
//  import Vue from 'vue'
 import { UserInfo } from '../api/user'
 
 export const namespace = 'user'
 
 export default {
   namespaced : true,
   state: {
    user: null,
    count: 10,
    test: {
      name: 'kizi'
    }
   },
   getters: {
    userName :state => {
      return state.user?.name || '默认值'
    },
    userCount: state => {
      return state.count*10
    }
  },
   mutations: {
     set_isLogin(state, val) {
       state.isLogin = val
     },
     setState(state, payload) {
       console.log({setState: payload})
       state.user = payload.user
       console.log({state})
     }
   },
   actions: {
     async getUserInfo({ commit }, { payload }) {
      const result = await UserInfo(payload)
      commit('setState',{
          user: result.data
      })
      return result;
     }
 
   }
 }